﻿Imports Cls_Common
Imports VSModel
Imports System.Data
Partial Class FrontEnd_Control_Menu_LeftMenu
    Inherits System.Web.UI.UserControl

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            BindMenu()
        End If
    End Sub
    Protected Sub BindMenu()
        Using Data As New VSEntities
            Dim p = (From q In Data.Menus Select q Order By q.Sort).ToList
            With rptMenu
                .DataSource = p
                .DataBind()
            End With
        End Using
    End Sub


    Protected Sub rptMenu_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptMenu.ItemDataBound
        Dim row As VSModel.Menu = CType(e.Item.DataItem, VSModel.Menu)
        Dim hplTitle As HyperLink = CType(e.Item.FindControl("hplTitle"), HyperLink)
        hplTitle.Text = row.Title
        hplTitle.NavigateUrl = MainDomain & "content/" & row.QueryString & "-" & row.MenuId & ".html"
        If Page.RouteData.Values("Id") = row.MenuId Then
            hplTitle.CssClass = "active"
        End If
    End Sub
End Class
